import { getToken } from "@/utils/token";
import { sendRequest } from "@/utils/http/interceptors";

/**
 * 请求拦截器处理
 *
 * @param {Object} _ Axios
 * @param {Object} config Axios Config
 * @returns {Object} Axios Config
 * @returns {Promise} Error
 */
export function interceptorHandle(_, config) {
  const { accessToken } = getToken();
  config.headers.Authorization = accessToken || "";
  return sendRequest.execute(config);
}

/**
 * 请求错误拦截器处理
 *
 * @param {Object} _ Axios
 * @param {Object} error Axios Error
 * @returns {Promise} Axios Error
 */
export function interceptorExceptionHandle(_, error) {
  return Promise.reject(error);
}
